package com.bba.manager.sku.controller;

import com.bba.manager.common.model.sku.Parts;
import com.bba.manager.common.model.sku.VO.partsQuery;
import com.bba.manager.common.util.ResponseVO;
import com.bba.manager.sku.service.impl.PartsServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 4S店配件表 前端控制器
 * </p>
 *
 * @author SYANDZZY
 * @since 2025-08-12
 */
@RestController
@RequestMapping("/parts")
public class PartsController {
    @Autowired
    private PartsServiceImpl partsService;
    @PostMapping("/add")
    public ResponseVO add(Parts parts){
        return ResponseVO.success(partsService.save(parts));
    }
    @DeleteMapping("/deleted")
    public ResponseVO deleted(Long id){
        return ResponseVO.success(partsService.removeById(id));
    }
    @PostMapping("/update")
    public  ResponseVO update(Parts parts){
        return ResponseVO.success(partsService.updateById(parts));
    }
    @GetMapping("/getone")
    public ResponseVO getone(Long id){
        return ResponseVO.success(partsService.getById(id));
    }
    @GetMapping("/fetchParts")
    public ResponseVO getall(){
        return ResponseVO.success(partsService.list());
    }
    @GetMapping("/partList")
    public ResponseVO partList(partsQuery query){
        return ResponseVO.success(partsService.listByInfo(query));
    }




}
